<!DOCTYPE html>
<html lang="en" class="app">
<head>
    <meta charset="utf-8" />
    <title>无线公共支持综合网管理平台</title>
    <meta name="description" content="app, web app, responsive, admin dashboard, admin, flat, flat ui, ui kit, off screen nav" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/css/bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/css/animate.css" type="text/css" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/css/icon.css" type="text/css" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/css/font.css" type="text/css" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/css/app.css" type="text/css" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/ui/kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/ui/zTree/css/zTreeStyle/zTreeStyle.css" />
    <link rel="stylesheet" href="__ROOT__/Public/admin/css/bianfeng.css" type="text/css" />
    <!--[if lt IE 9]>
    <script src="__ROOT__/Public/admin/js/ie/html5shiv.js"></script>
    <script src="__ROOT__/Public/admin/js/ie/respond.min.js"></script>
    <script src="__ROOT__/Public/admin/js/ie/excanvas.js"></script><![endif]-->
</head>
<body class="">
<section class="vbox">
    <include file="Public:header" />
    <section>
        <section class="hbox stretch">
            <aside class="bg-black aside-md hidden-print hidden-xs" id="nav">
                <include file="Public:left" />
            </aside>
            <section id="content">
                <section class="hbox stretch">
                    <section>
                        <section class="vbox">
                            <section class="scrollable padder">
                                <div class="m-b-md">
                                    <h3 class="m-b-none">发布新文章</h3>
                                </div>
                                <section class="panel panel-default">
                                    <div class="panel-body">

                                        <form class="form-horizontal" method="post" action="{:U('Admin/Article/AddArticle', '', false, true)}" name="form_text" id="form_text" data-validate="parsley">

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">标题</label>

                                                <div class="col-sm-10">
                                                    <input name="article_column" type="hidden" value="{$article.article_column}" id="ztree_id">
                                                    <input name="article_id" type="hidden" value="{$article.article_id}">
                                                    <input name="isedit" type="hidden" value="{$isedit}">
                                                    <input name="article_name" type="text" class="form-control" placeholder="请输入标题" value="{$article.article_name}" data-required="true" />
                                                </div>
                                            </div>
                                            <div class="line line-dashed b-b line-lg pull-in"></div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">文章摘要</label>

                                                <div class="col-sm-10">
                                                    <textarea name="article_remark" id="max_length_input" class="form-control parsley-validated" maxlength="100" rows="3" data-required="true" placeholder="文章摘要内容不超过100字">{$article.article_remark}</textarea>

                                                    <p class="max_p"><span id="max_no">0</span>/100</p>
                                                </div>
                                            </div>
                                            <div class="line line-dashed b-b line-lg pull-in"></div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">文章内容</label>

                                                <div class="col-sm-10">
                                                    <textarea name="content" style="width:100%;height:400px;visibility:hidden;" data-required="true">{$article.article_content}</textarea>
                                                </div>
                                            </div>
                                            <div class="line line-dashed b-b line-lg pull-in"></div>
                                            <div class="form-group">
                                                <div class="col-sm-4 col-sm-offset-2">
                                                    <button type="button" class="btn btn-default" id="btn_back">取消</button>
                                                    <button type="submit" class="btn btn-primary" id="fabu">发布</button>
                                                </div>
                                            </div>
                                        </form>

                                    </div>
                                </section>
                            </section>
                        </section>
                    </section>
                    <aside class="aside-md">
                        <section class="vbox">
                            <section class="scrollable wrapper-md bg-light dker">
                                <h5 class="font-semibold">选择栏目</h5>
                                <ul id="treeDemo" class="ztree"></ul>
                            </section>
                        </section>
                    </aside>
                </section>
                <a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen,open" data-target="#nav,html"></a>
            </section>
        </section>
    </section>
</section>
<script src="__ROOT__/Public/admin/js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="__ROOT__/Public/admin/js/bootstrap.js"></script>
<!-- App -->
<script src="__ROOT__/Public/admin/js/bianfeng.js"></script>
<script src="__ROOT__/Public/admin/js/app.js"></script>
<!-- parsley -->
<script src="__ROOT__/Public/admin/js/parsley/parsley.min.js"></script>
<script src="__ROOT__/Public/admin/js/parsley/parsley.extend.js"></script>

<script src="__ROOT__/Public/admin/js/chosen/chosen.jquery.min.js"></script>
<script src="__ROOT__/Public/admin/ui/zTree/js/jquery.ztree.core-3.5.js"></script>
<script>
    var fabu = $('#fabu');
    var form_text = $('#form_text');
    var ztree_id;
    var hidden_input = $('#ztree_id');
    var setting = {
        data: {
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeClick: beforeClick,
            onClick: onClick
        }
    };

    var zNodes = [

        {id: 0, pId: 0, name: "首页", open: true, click: false},
        {id: 1, pId: 0, name: "产品库", open: true, click: false},
        {id: 6, pId: 1, name: "角色扮演"},
        {id: 7, pId: 1, name: "枪战射击"},
        {id: 8, pId: 1, name: "动作冒险"},
        {id: 9, pId: 1, name: "赛车竞速"},
        {id: 10, pId: 1, name: "策略战棋"},
        {id: 11, pId: 1, name: "即时战略"},
        {id: 12, pId: 1, name: "体育竞技"},
        {id: 13, pId: 1, name: "模拟经营"},
        {id: 14, pId: 1, name: "恋爱养成"},
        {id: 2, pId: 0, name: "评级评测", open: true, click: false},
        {id: 15, pId: 2, name: "评级产品"},
        {id: 16, pId: 2, name: "评测产品"},
        {id: 3, pId: 0, name: "外包资源", open: true, click: false},
        {id: 17, pId: 3, name: "外包公司"},
        {id: 18, pId: 3, name: "美术资源"},
        {id: 4, pId: 0, name: "新闻故事", open: true, click: false},
        {id: 19, pId: 4, name: "部门事件"},
        {id: 20, pId: 4, name: "业务新闻"},
        {id: 21, pId: 4, name: "故事八卦"},
        {id: 5, pId: 0, name: "业务需求", open: true, click: false}


    ];

    //弹出对话框，父栏目不能选择
    function beforeClick(treeId, treeNode, clickFlag) {
        if (treeNode.isParent) {
            alert("这个 父栏目 是用来 展开 / 折叠 的...\n\n去点击他的子节点吧... ");
            return false;
        } else {
            return true;
        }
        return (treeNode.click != false);
    }

    //获取选中的id和name
    function onClick(event, treeId, treeNode, clickFlag) {
        ztree_id = treeNode.id;
        $('#ztree_id').val(ztree_id);

    }

    //判断树的id
    function ztree_ch() {
        form_text.submit(function () {
            if (hidden_input.val() == '' || hidden_input.val() == '0') {
                alert('请选择子栏目');
                return false;
            } else {
                return true;
            }
        });
    }

    $(document).ready(function () {
        $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        //ztree选中状态
        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        zTree.selectNode(zTree.getNodeByParam("id", hidden_input.val()));
        ztree_ch();
    });
</script>
<script src="__ROOT__/Public/admin/ui/kindeditor/kindeditor-min.js"></script>
<script src="__ROOT__/Public/admin/ui/kindeditor/lang/zh_CN.js"></script>
<script>
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="content"]', {
            uploadJson: "__ROOT__/Public/admin/ui/kindeditor/php/upload_json.php",
            fileManagerJson: "__ROOT__/Public/admin/ui/kindeditor/php/file_manager_json.php",
            allowFileManager: true,
            //同步之后不会出现这样的问题
            afterBlur: function () {
                //编辑器失去焦点时直接同步，可以取到值
                this.sync();
            }
        });
    });
</script>
</body>
</html>